﻿using System;

namespace Borg
{
    [Serializable]
    public class CompositionEventArgs : EventArgs
    {
        private readonly Slot _slot;
        private readonly Plug _plug;

        public Slot Slot
        {
            get { return _slot; }
        }

        public Plug Plug
        {
            get { return _plug; }
        }

        public CompositionEventArgs(Slot slot, Plug plug)
        {
            if (slot == null)
                throw new ArgumentNullException("slot");
            
            if (plug == null)
                throw new ArgumentNullException("plug");
            
            _slot = slot;
            _plug = plug;
        }

        public override bool Equals(object obj)
        {
            if (obj == this)
                return true;

            if (!(obj is CompositionEventArgs))
                return false;

            var compositionEventArgs = (CompositionEventArgs)obj;
            
            return
                Equals(_slot, compositionEventArgs._slot) &&
                Equals(_plug, compositionEventArgs._plug);
        }

        public override int GetHashCode()
        {
            return
                _slot.GetHashCode() ^
                _plug.GetHashCode();
        }
    }
}
